#include "wds_bullet_sfx.h"
#include "wds_sfx_manager.h"



WDSBulletSfx::WDSBulletSfx(float Speed, 
						   WDSSfx::SFX_TYPES	SfxType 
						   ) :	WDSBullet(	Speed,
											false,
											1.0f,
											WDSBullet::BULLET_TYPE_FLAME
											),
											m_pSfx(NULL),
											m_SfxType(SfxType)											
{
	m_Radius = 0.025f;	
	m_Howlong = m_Radius * 10;
}




void		WDSBulletSfx::Tick(float dt, float SkillBulletSpeed, const math::Vec2& Offset)
{
	WDSBullet::Tick(dt, SkillBulletSpeed, Offset);
	if(m_pSfx && m_IsAlive)
		m_pSfx->FollowMe(GetPos() );

	if(!m_IsAlive &&  m_pSfx)
	{
		m_pSfx->ToDie();
		m_pSfx = NULL;
	}
}

void		WDSBulletSfx::ReSpawn(const math::Vec2& Pos,
								WDSBullet::STARTPOS StartDir,
								float Degree							
								)
{
	WDSBullet::ReSpawn(Pos,StartDir,Degree);
	m_pSfx = WDSSFXManager::Instance().Spawn(m_SfxType,Pos,1.0f,0);
	//m_pSfx->SetRotation(m_Rotation + 18.0f);
}

void		WDSBulletSfx::Kill() 
{ 
	WDSBullet::Kill();
	if(m_pSfx)
	{
		m_pSfx->ToDie();
		m_pSfx = NULL;
	}
	
};


